package com.example.vue.data;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class ECommerceCategoryData {

    public static class MainCategory {
        private Long id;
        private String name;
        private String url;
        private List<SubCategory> subCategories = new ArrayList<>();

        // Constructor
        public MainCategory() {}

        public MainCategory(Long id,String name, String url) {
            this.id = id;
            this.name = name;
            this.url = url;
        }

        // Getters and Setters

        public Long getId() {
            return id;
        }

        public void setId(Long id) {
            this.id = id;
        }

        public String getName() { return name; }
        public void setName(String name) { this.name = name; }
        public String getUrl() { return url; }
        public void setUrl(String url) { this.url = url; }
        public List<SubCategory> getSubCategories() { return subCategories; }
        public void setSubCategories(List<SubCategory> subCategories) {
            this.subCategories = subCategories;
        }
    }

    public static class SubCategory {
        private Long id;
        private String name;
        private String url;
        private List<String> thirdNames = new ArrayList<>();

        // Constructor
        public SubCategory() {}

        public SubCategory(Long id,String name, String url) {
            this.id=id;
            this.name = name;
            this.url = url;
        }

        // Getters and Setters

        public Long getId() {
            return id;
        }

        public void setId(Long id) {
            this.id = id;
        }

        public String getName() { return name; }
        public void setName(String name) { this.name = name; }
        public String getUrl() { return url; }
        public void setUrl(String url) { this.url = url; }
        public List<String> getThirdNames() { return thirdNames; }
        public void setThirdNames(List<String> items) { this.thirdNames = items; }
    }

    public static Map<String, Object> generateFullData() {
        Map<String, Object> data = new HashMap<>();

        // 1. 顶部导航
        List<String> topNav = List.of(
                "服装城", "美妆馆", "尚品汇超市", "全球购", "闪购", "团购", "有趣", "秒杀"
        );
        data.put("topNav", topNav);

        // 2. 主分类列表
        List<MainCategory> categories = new ArrayList<>();

        // 图书、音像、数字商品
        MainCategory bookCategory = new MainCategory(1L,"图书、音像、数字商品", "###");

        SubCategory ebook = new SubCategory(11L,"电子书", "###");
        ebook.setThirdNames(List.of("婚恋/两性", "文学", "经管", "畅读VIP"));
        bookCategory.getSubCategories().add(ebook);

        categories.add(bookCategory);

        // 家用电器
        MainCategory appliance = new MainCategory(2L, "家用电器", "###");

        SubCategory ebook1 = new SubCategory(21L,"电子书1", "###");
        ebook1.setThirdNames(List.of("免费", "小说", "励志与成功", "婚恋/两性", "文学", "经管", "畅读VIP"));

        SubCategory digitalMusic = new SubCategory(22L,"数字音乐", "###");
        digitalMusic.setThirdNames(List.of("通俗流行", "古典音乐", "摇滚说唱", "爵士蓝调", "乡村民谣", "有声读物"));

        SubCategory audioVideo = new SubCategory(23L,"音像", "###");
        audioVideo.setThirdNames(List.of("音乐", "影视", "教育音像", "游戏"));

        appliance.getSubCategories().addAll(List.of(ebook1, digitalMusic, audioVideo));
        categories.add(appliance);

        // 手机、数码、充值
        MainCategory mobile = new MainCategory(3L,"手机、数码、充值", "###");

        SubCategory recharge = new SubCategory(31L,"充值", "###");
        recharge.setThirdNames(List.of("充值"));

        SubCategory ebook2 = new SubCategory(32L,"电子书2", "###");
        ebook2.setThirdNames(List.of("免费", "小说", "励志与成功", "婚恋/两性", "文学", "经管", "畅读VIP"));

        mobile.getSubCategories().addAll(List.of(recharge, ebook2));
        categories.add(mobile);

        // 可以继续添加其他分类...

        data.put("categories", categories);
        return data;
    }

    public static void main(String[] args) {
        Map<String, Object> data = generateFullData();

        // 打印数据
        System.out.println("=== 电商分类数据 ===");
        System.out.println("\n顶部导航:");
        ((List<String>) data.get("topNav")).forEach(System.out::println);

        System.out.println("\n商品分类结构:");
        ((List<MainCategory>) data.get("categories")).forEach(category -> {
            System.out.println("\n[" + category.getName() + "]");
            category.getSubCategories().forEach(sub -> {
                System.out.println("  ├─ " + sub.getName());
                sub.getThirdNames().forEach(item -> System.out.println("  │   ├─ " + item));
            });
        });
    }
}